<template>
  <div class="page home">
    <div class="row info">
      <div class="title">你好！</div>
      <div class="intro">{{intro}}</div>
    </div>
    <div class="row message">
      <div class="col col-1">
        <div v-for="(item, index) in imgArr[0]" :key="index" class="item-container">
          <div class="item">
            <img :src="item.cover" @click="linkToPage(item.detail)"/>
            <div class="info-mask" v-if="item.link" @click="linkToPage(item.link)">
              <div class="info-title">{{item.title}}</div>
              <div class="info-time">上映时间：{{item.time}}</div>
              <div class="info-role">饰演：{{item.role}}</div>
              <div class="info-content">{{item.content}}</div>
            </div>
          </div>
        </div>
      </div>
      <div class="col col-2">
        <div v-for="(item, index) in imgArr[1]" :key="index" class="item-container">
          <div class="item">
            <img :src="item.cover" @click="linkToPage(item.detail)"/>
            <div class="info-mask" v-if="item.link" @click="linkToPage(item.link)">
              <div class="info-title">{{item.title}}</div>
              <div class="info-time">上映时间：{{item.time}}</div>
              <div class="info-role">饰演：{{item.role}}</div>
              <div class="info-content">{{item.content}}</div>
            </div>
          </div>
        </div>
      </div>
      <div class="col col-3">
        <div v-for="(item, index) in imgArr[2]" :key="index" class="item-container">
          <div class="item">
            <img :src="item.cover" @click="linkToPage(item.detail)"/>
            <div class="info-mask" v-if="item.link" @click="linkToPage(item.link)">
              <div class="info-title">{{item.title}}</div>
              <div class="info-time">上映时间：{{item.time}}</div>
              <div class="info-role">饰演：{{item.role}}</div>
              <div class="info-content">{{item.content}}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="footer">
      <div class="author">designed by wucl</div>
    </div>
  </div>
</template>

<script>
import imgArr from '../data/home'

export default {
  name: 'home',
  data() {
    return {
      intro: '李现，1991年10月19日出生于湖北省咸宁市，成长于湖北省荆州市，中国内地影视男演员，毕业于北京电影学院表演系2010级。',
      imgArr: imgArr
   }
  },
  methods: {
    linkToPage(url) {
      window.open(url)
    }
  }
}
</script>

<style scoped>
  .info {
    align-items: flex-start;
    margin: 18px auto;
  }
  .title {
    width: 300px;
    height: 120px;
    margin-right: 30px;
    font-size: 56px;
    line-height: 65px;
  }
  .message {
    border-top: 5px solid #323232;
    justify-content: space-between;
    align-items: flex-start;
  }
  .message img {
    width: 339px;
  }
  .home .item-container {
    margin-bottom: 1px;
  }
  .item {
    position: relative;
    cursor: pointer;
  }
  .info-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 28px 16px;
    font-size: 18px;
  }
  .info-mask .info-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 16px;
  }
  .info-mask .info-content {
    font-size: 14px;
    line-height: 22px;
    margin-top: 16px;
  }
  .info-mask {
    display: none;
  }
  .item:hover .info-mask {
    display: block;
  }
  .footer {
    border-top: 1px solid #323232;
    position: relative;
    margin-top: 30px;
    margin-bottom: 20px;
  }
  .footer .author {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #fffff3;
    width: 180px;
    height: 30px;
    text-align: center;
    line-height: 30px;
    padding-bottom: 2px;
    font-family: fantasy;
  }
  .intro {
    line-height: 33px;
  }
  @media screen and (max-width: 768px){
    .title {
      width: 100px;
      height: 60px;
      line-height: 40px;
      margin-right: 18px;
      font-size: 30px;
      flex-shrink: 0;
      margin-top: 2px;
    }
    .message {
      width: 100%;
      flex-wrap: wrap;
    }
    /* .col-1 {
      margin-right: 1px;
    } */
    .col-1, .col-2 {
      width: 50%;
      box-sizing: border-box;
    }
    .item-container {
      margin-bottom: -2px;
    }
    .col-1 .item-container {
      padding-right: 2px;
    }
    .col-3 {
      width: 100%;
      box-sizing: border-box;
      flex-direction: row;
      flex-wrap: wrap;
    }
    .message img {
      width: 100%;
    }
    .info {
      padding: 0 12px;
      margin-top: 0;
      margin-bottom: 28px;
    } 
    .footer {
      margin-top: 40px;
      margin-bottom: 28px;
    }
  }
</style>
